<template>
  <div class="home">
    <el-button
      class="button upload"
      size="large"
      type="success"
      @click="onUploadClick"
    >
      上传安装包
    </el-button>
    <el-button
      @click="onDownloadClick"
      class="button download"
      size="large"
      type="primary"
    >
      下载安装包
    </el-button>
    <el-dialog v-model="dialogVisible" width="360px" center>
      <template #title>
        <div>用户登录</div>
      </template>
      <el-form :model="form" label-position="top">
        <el-form-item label="用户名">
          <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.password" type="password" show-password />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button class="dialog-button" type="primary" @click="onLoginClick">
          登录
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
// import HelloWorld from "@/components/HelloWorld.vue";
import client from "@/api/client.js";
export default {
  name: "HomeView",
  components: {},
  props: {},
  data() {
    return {
      dialogVisible: false,
      form: {},
    };
  },
  methods: {
    onLoginClick() {
      // this.dialogVisible = false;
      client
        .login({
          name: "tom",
          password: "jerry",
        })
        .then(function (response) {
          console.log(response);
        })
        .catch(function (err) {
          console.log(err);
        });
    },
    onDownloadClick() {
      this.$router.push({
        path: "/download",
      });
    },
    onUploadClick() {},
  },
};
</script>
<style scoped>
.home {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  flex-direction: column;
}
.button {
  margin-left: 0 !important;
}
.upload {
}
.download {
  margin-top: 20px;
}
.dialog-button {
  width: 310px;
}
</style>
